from pydantic import BaseModel, ConfigDict, UUID4, Field, field_validator
from sqlalchemy.orm import declarative_base
# from sqlalchemy import Column, String, Uuid, LargeBinary, Float
from uuid import uuid4
from typing import Optional
from typing_extensions import Required
import datetime
import json


Base = declarative_base()


# class User(Base):
#     __tablename__ = "users"
#
#     id = Column(Uuid, primary_key=True)
#     username = Column(String(55), nullable=False)
#     password = Column(LargeBinary, nullable=False)
#     created_at = Column(Float, nullable=False)
#     updated_at = Column(Float)


class UserWithoutPassword(BaseModel):
    model_config = ConfigDict(from_attributes=True)

    id: UUID4 = Field(alias="user_id", frozen=True)
    username: str = Field(max_length=55)
    created_at: float = Field(frozen=True)
    updated_at: float | None = None


class User(UserWithoutPassword):
    password: bytes


class NewUserData(User):
    id: UUID4 | None = None
    created_at: float | None = None
    password: str


class Booking(BaseModel):
    model_config = ConfigDict(from_attributes=True)

    id: UUID4 = Field(alias="booking_id", frozen=True)
    user_id: UUID4
    start_time: float
    end_time: float
    comment: str = Field(max_length=255)
    created_at: float = Field(frozen=True)
    updated_at: float | None = None


class NewBookingData(Booking):
    id: UUID4 | None = None
    created_at: float | None = None
